import copy

row, col = 5, 6
move = [[0, 1], [0, -1], [1, 0], [-1, 0]]


# 判断是否越界
def check_out(x, y):
    return 0 <= x < row and 0 <= y < col


# 灯状态改变
def change(x, y, temp):
    temp[x][y] = 1 - temp[x][y]


# 按开关
def press(x, y, temp, button):
    change(x, y, temp)
    button[x][y] = 1

    # 四周灯状态改变
    for i in range(len(move)):
        temp_x, temp_y = x + move[i][0], y + move[i][1]
        if check_out(temp_x, temp_y):
            change(temp_x, temp_y, temp)


# 判断是否全关
def isOK(temp):
    for i in range(row):
        for j in range(col):
            if temp[i][j]:
                return False
    return True


def main():
    global button
    lamp = []
    # 输入灯泡初始状态
    for i in range(row):
        lamp.append(input().split(' '))
    for i in range(row):
        for j in range(col):
            lamp[i][j] = int(lamp[i][j])

    # 枚举第一行灯泡状态 2^6种
    for i in range(1 << col):
        # 初始化temp button
        temp = copy.deepcopy(lamp)
        # print(temp)
        button = [[0 for _ in range(col)] for _ in range(row)]

        # 第一行枚举
        for j in range(col):
            # print(bin(i), bin(j))
            if i >> j & 1:
                # print(bin(i >> j))
                press(0, j, temp, button)

        # 后面四行
        for j in range(1, row):
            for k in range(col):
                if temp[j - 1][k]:
                    press(j, k, temp, button)

            # print(temp)

        if isOK(temp):
            break

    for i in range(row):
        for j in range(col):
            print(button[i][j], end=' ')
        print('')


main()
